package com.imaker.frame.utils

import android.annotation.SuppressLint
import android.content.Context
import com.lxj.xpopup.XPopup
import com.lxj.xpopup.impl.LoadingPopupView

/**
 * @Description:页面展示loading
 * @author ziheng
 * @date 2022/12/5 16:07
 */
object LoadingViewUtil {
    @SuppressLint("StaticFieldLeak")
    private var loading: LoadingPopupView? = null

    fun showLoadingDialog(context: Context) {
        if (loading == null) {
            loading = LoadingPopupView(context,0)
            XPopup.Builder(context)
                .asCustom(loading)
                .show()
        } else {
            loading?.show()
        }
    }

    fun dismissLoadingDialog() {
        loading?.dismiss()
    }
}